package com.ruoyi.other.controller;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.other.domain.EBulletin;
import com.ruoyi.other.service.IEBulletinService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 广播公告Controller
 * 
 * @author ruoyi
 * @date 2024-11-21
 */
@RestController
@RequestMapping("/bulletin")
public class EBulletinController extends BaseController
{
    @Autowired
    private IEBulletinService eBulletinService;

    /**
     * 查询广播公告列表
     */
    @RequiresPermissions("other:bulletin:list")
    @GetMapping("/list")
    public TableDataInfo list(EBulletin eBulletin)
    {
        startPage();
        List<EBulletin> list = eBulletinService.selectEBulletinList(eBulletin);
        return getDataTable(list);
    }


    /**
     * 获取广播公告详细信息
     */
    @RequiresPermissions("other:bulletin:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eBulletinService.selectEBulletinById(id));
    }
    /**
     * 新增广播公告
     */
    @RequiresPermissions("other:bulletin:add")
//    @Log(title = "广播公告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EBulletin eBulletin)
    {
        eBulletin.setCreationtime(new Date());
        eBulletin.setStatus(1);
        return toAjax(eBulletinService.insertEBulletin(eBulletin));
    }


    /**
     * 删除广播公告
     */
    @RequiresPermissions("other:bulletin:remove")
//    @Log(title = "广播公告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eBulletinService.deleteEBulletinByIds(ids));
    }

    /**
     * 修改广播公告状态
     */
	@PostMapping("updateStatus")
    public AjaxResult remove(@RequestBody EBulletin eBulletin)
    {
        return toAjax(eBulletinService.updateByid(eBulletin));
    }
}
